


import sys, os
os.chdir('..')
sys.path.append('..')


import pyrind
from pyrind import RWindow
from pyrind import RField
import testcase
	
class MyApplication():
	def __init__(self,w):
		w.title = 'Welcome'
		
		#use a grid, because can specify minimum size/width
		f = w.begin_frame()
		f.set_row_weight(0,minsize=300)
		f.set_col_weight(0,minsize=300)
		with w.add_frame(grid=(0,0)):
			fld1 = w.add_field('One',width=30, height=3, undo=True)
			fld2 = w.add_field('Two',width=30, height=3, undo=True, scrollbar=True)
		
		flds=(fld1, fld2)
		w.end_frame()
		
		w.begin_frame()
		otestcase = testcase.TestCaseOpt(w)
		otestcase.addProperty(flds, 'text', ['changing text','some\ntext\nwith\nnew lines'*5,'a really long line of text that continues '*30])
		otestcase.addProperty(flds, 'bgcolor', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(flds, 'color', ['black','red',(255,0,64), (255,0,128)])
		otestcase.addProperty(flds, 'highlightcolor', ['black','red',(255,0,64), (255,0,128)])
		
		
		otestcase.addProperty(flds, 'enabled', [True, False ])
		otestcase.addProperty(flds, 'borderwidth', [0,1,2,3,4 ])
		otestcase.addProperty(flds, 'wrap',  [None,'none','char','word' ])
		
		otestcase.addRow()
		otestcase.addProperty(flds, 'font', [None, 'times','helvetica','courier', ('Lucida Console', 16, 'normal'),('Verdana', 6, 'normal') ])
		
		otestcase.addProperty(flds, 'wrapwidth',  [0,10,20,30,40,50,60 ])
		otestcase.addProperty(flds, 'alignment',  ['left','right','center' ])
		otestcase.addProperty(flds, 'borderstyle', ['sunken','raised','groove','ridge','flat'])
		otestcase.addProperty(flds, 'width',  [0,10,20,30,40,50,60 ])
		otestcase.addProperty(flds, 'height', [0,1,2,3 ])
		
		otestcase.addRow()
		
		def callmethod(method, *args):
			r1 = method(flds[0], *args)
			r2 = method(flds[1], *args)
			print ('r1: "%s" r2: "%s"'%(r1,r2))
			return None
		otestcase.addMethod('get_selected_text',lambda: callmethod(RField.get_selected_text))
		otestcase.addMethod('get_selection',lambda: callmethod(RField.get_selection))
		otestcase.addMethod('deselect',lambda: callmethod(RField.deselect))
		otestcase.addMethod('highlight_clear',lambda: callmethod(RField.highlight_clear))
		otestcase.addMethod('highlight_line',lambda: callmethod(RField.highlight_line, 1))
		otestcase.addMethod('highlight_chars',lambda: callmethod(RField.highlight_line, 2,4))
		
		w.end_frame()
		
		w.start()
		

app = MyApplication(RWindow())



